<template>
  <div>
    <el-row :gutter="6">
      <el-form ref="orderForm" :model="orderData" :rules="rules" size="mini" label-width="60px">
        <el-col :span="9">
          <el-form-item label="单号" prop="orderNo">
            <el-input v-model="orderData.orderNo" @keyup.enter.native="scanReturned" placeholder="请扫描或输入运单号/追踪号回车后扫描退件" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
  </div>
</template>
<script>
import {ajax} from "@/store/yg/common/utils";

export default {
  components: {},
  props: [],
  data() {
    return {
      orderData: {
        orderNo: '',
      },
      rules: {
        orderNo: [{
          required: true,
          message: '请扫描或输入运单号/追踪号',
          trigger: 'blur'
        }],
      },
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    scanReturned() {
      console.log("scanReturned!");
      
      if (JSON.stringify(this.orderData.orderNo) === "{}" || this.orderData.orderNo.length==null || this.orderData.orderNo.length==0) {
        this.$message.error('请输入主单号');
      } else {
        var data = {};
        data["orderNo"] = this.orderData.orderNo;
        ajax("scanReturned",data).then(
          res => {
            console.log(res);
            if (res.code != 200) {
              this.$message.error(res.message);
            }else{
               this.$message.success('退件单号扫描成功！');
            }
          },
          error => {
            console.log(error);
          }
        );
      }
    },
  }
}

</script>
<style>
</style>
